$(document).ready(function(){
	//style select box
	$('select').customStyle();
	
	//style check box
	$('input:checkbox:not([onoff])').checkbox({cls:'jquery-safari-checkbox'});
	//$('input:checkbox:not([safari])').checkbox();
	$('input[onoff]:checkbox').checkbox();
	//slideshow
	$("div.background-images-slideshow").carousel({
		dispItems:1,
		pagination:true,
		autoSlide:false,
		nextBtn: null,
		prevBtn: null
	});
	$("div.image-slideshow").carousel({
		dispItems:1,
		pagination:true,
		autoSlide:false,
		nextBtn: null,
		prevBtn: null		
	});
	
	$("#accordion").accordion();
	
	$("#personal-tabs").tabs({
		select: function(event, ui) {
			//alert(ui.index);
			$("ul.ui-tabs-nav li").removeClass("ui-tabs-next-to-selected");
			li = $("ul.ui-tabs-nav li").get(ui.index + 1)
			$(li).addClass("ui-tabs-next-to-selected");
			if(ui.index != 0){
				liFirst = $("ul.ui-tabs-nav li").get(0)
				$(liFirst).addClass("ui-tabs-first-non-selected");
			}else{
				liFirst = $("ul.ui-tabs-nav li").get(0)
				$(liFirst).removeClass("ui-tabs-first-non-selected");
			}
			
			if(ui.index >= $("#personal-tabs > ul.ui-tabs-nav li").length-2){
				liLast = $("#personal-tabs > ul.ui-tabs-nav li").get($("#personal-tabs > ul.ui-tabs-nav li").length-1);
				$(liLast).removeClass("ui-tabs-last-non-selected");
				$(liLast).addClass("ui-tabs-last-selected");	
			}else{
				liLast = $("#personal-tabs > ul.ui-tabs-nav li").get($("#personal-tabs > ul.ui-tabs-nav li").length-1);
				$(liLast).addClass("ui-tabs-last-non-selected");
			}
		}
	});
	$("#description-tabs").tabs({
		select: function(event, ui) {
			//alert(ui.index);
			$("#description-tabs > ul.ui-tabs-nav li").removeClass("ui-tabs-next-to-selected");
			li = $("#description-tabs > ul.ui-tabs-nav li").get(ui.index + 1)
			$(li).addClass("ui-tabs-next-to-selected");
			if(ui.index != 0){
				liFirst = $("#description-tabs > ul.ui-tabs-nav li").get(0)
				$(liFirst).addClass("ui-tabs-first-non-selected");
			}else{
				liFirst = $("#description-tabs > ul.ui-tabs-nav li").get(0)
				$(liFirst).removeClass("ui-tabs-first-non-selected");
			}
			
			if(ui.index >= $("#description-tabs > ul.ui-tabs-nav li").length-2){
				liLast = $("#description-tabs > ul.ui-tabs-nav li").get($("#description-tabs > ul.ui-tabs-nav li").length-1);
				$(liLast).removeClass("ui-tabs-last-non-selected");
				$(liLast).addClass("ui-tabs-last-selected");	
			}else{
				liLast = $("#description-tabs > ul.ui-tabs-nav li").get($("#description-tabs > ul.ui-tabs-nav li").length-1);
				$(liLast).addClass("ui-tabs-last-non-selected");
			}
		}
	});
	
	//slider
	$( "#slider-age").slider({
		orientation: "horizontal",
		range: "min",
		min: 0,
		max: 100,
		value: 60,
		slide: function( event, ui ) {
			//$( "#amount" ).val( ui.value );
		}
	});
	$( "#slider-price").slider({
		orientation: "horizontal",
		range: "min",
		min: 0,
		max: 100,
		value: 60,
		slide: function( event, ui ) {
			//$( "#amount" ).val( ui.value );
		}
	});
	$( "#slider-size-breast").slider({
		orientation: "horizontal",
		range: "min",
		min: 0,
		max: 100,
		value: 60,
		slide: function( event, ui ) {
			//$( "#amount" ).val( ui.value );
		}
	});

	// complete tab ui
	if($("ul.ui-tabs-nav").length){
		$("ul li.ui-tabs-selected").next().addClass("ui-tabs-next-to-selected");
		liLast = $("#personal-tabs > ul.ui-tabs-nav li").get($("#personal-tabs > ul.ui-tabs-nav li").length-1);
		$(liLast).addClass("ui-tabs-last-non-selected");
		liLast1 = $("#description-tabs > ul.ui-tabs-nav li").get($("#description-tabs > ul.ui-tabs-nav li").length-1);
		$(liLast1).addClass("ui-tabs-last-non-selected");
	}
});